Move icon_descr_is_dynamic and shortname_is_synthetic into a bitfield.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 11 Apr 2005 21:07:16 +0000 (21:07 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 11 Apr 2005 21:07:16 +0000 (21:07 +0000)
gpsbabel/csv_util.c
gpsbabel/defs.h
gpsbabel/geo.c
gpsbabel/geoniche.c
gpsbabel/gpilots.c
gpsbabel/gpx.c
gpsbabel/hiketech.c
gpsbabel/jeeps/gpsport.h
gpsbabel/mingw/wintesto.cmd
gpsbabel/route.c
gpsbabel/waypt.c

index 26625e4fae3b711f3de054faade291ac49500d43..42d67b9852ff80f64b1fbceee74ae3a497975f5b 100644 (file)
@@ -639,7 +639,7 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp)
     } else
     if (strcmp(fmp->key, "ICON_DESCR") == 0) {
        wpt->icon_descr = csv_stringtrim(s, "", 0);
-       wpt->icon_descr_is_dynamic = 1;
+       wpt->wpt_flags.icon_descr_is_dynamic = 1;
     } else
 
     /* LATITUDE CONVERSIONS**************************************************/
index ae933b01fad5a8471cda237501bd2cce4eccb54e..e979c6d8615ef948960815395a593d9dc5dd41b7 100644 (file)
@@ -158,12 +158,21 @@ typedef struct {
        an1_copy copy;
 } an1_base;
 
+/*
+ * Misc bitfields inside struct waypoint;
+ */
+typedef struct {
+       unsigned int icon_descr_is_dynamic:1; 
+       unsigned int shortname_is_synthetic:1;
+} wp_flags;
+
 /*
  * This is a waypoint, as stored in the GPSR.   It tries to not 
  * cater to any specific model or protocol.  Anything that needs to
  * be truncated, edited, or otherwise trimmed should be done on the
  * way to the target.
  */
+
 typedef struct {
        queue Q;                        /* Master waypoint q.  Not for use
                                           by modules. */
@@ -208,8 +217,8 @@ typedef struct {
        char *notes;
        char *url;
        char *url_link_text;
-       int icon_descr_is_dynamic;
-       int shortname_is_synthetic;
+
+       wp_flags wpt_flags;
        const char *icon_descr;
        time_t creation_time;   /* standardized in UTC/GMT */
        int centiseconds;       /* Optional hundredths of a second. */
index c93cdc5590e86a79505b2a3e42533748718b4531..c8ace7244c0d4def231660419f110069b4b74704 100644 (file)
@@ -109,7 +109,7 @@ void wpt_link(const char *args, const char **attrv)
 
 void wpt_type(const char *args, const char **unused)
 {
-       wpt_tmp->icon_descr_is_dynamic = 1;
+       wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
        wpt_tmp->icon_descr = xstrdup(args);
 }
 
index ff4a5a5d54c09e2d7b0c35207662666bbceb2d7e..7fb0d4a7dc43630278e980c8d535fd647dde07d8 100644 (file)
@@ -335,7 +335,7 @@ data_read(void)
        wpt->longitude = lon;
        wpt->altitude = alt;
        wpt->icon_descr = category;
-       wpt->icon_descr_is_dynamic = 1;
+       wpt->wpt_flags.icon_descr_is_dynamic = 1;
 
        if (gid[0])
        {
index 24cd5e606381d8f59746eef0ebd027c875b8f6e9..6af407510b8e5b460d2af6124dad69a2f9f4ba1e 100644 (file)
@@ -277,7 +277,7 @@ data_read(void)
                          wpt_tmp->depth = fi.f;
                          fi.i = le_read32(&rec->wpt.d108.dist);
                          wpt_tmp->proximity = fi.f;
-                         wpt_tmp->icon_descr_is_dynamic = 0;
+                         wpt_tmp->wpt_flags.icon_descr_is_dynamic = 0;
                          wpt_tmp->icon_descr = mps_find_desc_from_icon_number((rec->wpt.d108.smbl[1] << 8) + rec->wpt.d108.smbl[0], PCX);
                          waypt_add(wpt_tmp);
                          break;
index 78f6590d73fc8e17126e64d717f9fc3d720c1ce7..1eb5d7021bd9aa4e8f49d731c426b0a23db78ca3 100644 (file)
@@ -750,7 +750,7 @@ gpx_end(void *data, const char *el)
        case tt_rte_rtept_sym:
        case tt_trk_trkseg_trkpt_sym:
                wpt_tmp->icon_descr = xstrdup(cdatastrp);
-               wpt_tmp->icon_descr_is_dynamic = 1;
+               wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
                break;
        case tt_wpt_time:
        case tt_trk_trkseg_trkpt_time:
@@ -1188,7 +1188,7 @@ gpx_track_disp(const waypoint *waypointp)
        /* GPX doesn't require a name on output, so if we made one up
         * on input, we might as well say nothing.
         */
-       if (!waypointp->shortname_is_synthetic) {
+       if (!waypointp->wpt_flags.shortname_is_synthetic) {
                write_optional_xml_entity(ofd, "  ", "name", 
                        waypointp->shortname);
        }
index bf09e4c095254bdaac2d603992d2f2efe9d83a91..a1d0264858bab0082eb7f0344f450b911e6d4847 100644 (file)
@@ -181,7 +181,7 @@ void        ht_ident(const char *args, const char **unused)
 void   ht_sym(const char *args, const char **unused)
 {
        wpt_tmp->icon_descr = xstrdup(args);
-       wpt_tmp->icon_descr_is_dynamic = 1;
+       wpt_tmp->wpt_flags.icon_descr_is_dynamic = 1;
 }
 
 void   ht_lat(const char *args, const char **unused)
index c640c42a72695e810c4ad5190d9ae66976e75bad..dd23cc4019c8987469e008fcf9c02e72e321976f 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 typedef unsigned char UC;
-typedef uint16        US;
+typedef gbuint16      US;
 typedef gbuint16      uint16;
 typedef gbint16       int16;
 typedef gbuint32      uint32;
index 17447921462dd7c6470de4b7865232bfaf3b6a43..86c14de10b253e21714699a8c9d5795144c7526b 100644 (file)
@@ -126,6 +126,27 @@ DEL %TMPDIR%\tiger
 @echo.\r
 CALL :COMPARE %TMPDIR%\tiger %TMPDIR%\tiger2\r
 \r
+REM \r
+REM Lowrance USR.  Binary, and also slightly lossy because of the math to\r
+REM convert lat/long.  It also doesn't support description, which makes it\r
+REM awkward  to test.\r
+REM \r
+DEL %TMPDIR%\lowrance1.usr\r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i geo -f geocaching.loc -o lowranceusr -F %TMPDIR%\lowrance1.usr\r
+@echo off\r
+@echo.\r
+CALL :BINCOMPARE %TMPDIR%\lowrance1.usr reference\lowrance.usr\r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i lowranceusr -f %TMPDIR%\lowrance1.usr -o lowranceusr -F %TMPDIR%\lowrance1.usr\r
+@echo off\r
+@echo.\r
+REM And because of the FP rounding, we can't even read our file, write it back\r
+REM and get the same data.  Sigh. \r
+REM bincompare reference/lowrance.usr  ${TMPDIR}/lowrance1.usr\r
+\r
 REM CSV (Comma separated value) data.\r
 \r
 @echo on\r
@@ -250,7 +271,7 @@ REM identical reference.
 %PNAME% -i holux -f reference\paris.wpo -o holux -F %TMPDIR%\paris.wpo\r
 @echo off\r
 @echo.\r
-CALL :COMPARE reference\paris.wpo %TMPDIR%\paris.wpo\r
+REM compare reference/paris.wpo ${TMPDIR}/paris.wpo\r
 \r
 REM Magellan NAV Companion for PalmOS\r
 REM This format is hard to test, because each record and the database itself\r
@@ -837,6 +858,59 @@ CALL :COMPARE %TMPDIR%\igc_sed.out reference\igc2_igc.out
 @echo.\r
 CALL :COMPARE %TMPDIR%\igc.gpx reference\igc2_gpx.out\r
 \r
+REM \r
+REM Google Maps XML test\r
+REM \r
+DEL %TMPDIR%\google.out\r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i google -f reference\google.xml -o arc -F %TMPDIR%\google.out\r
+@echo off\r
+@echo.\r
+CALL :COMPARE %TMPDIR%\google.out reference\google.arc\r
+\r
+DEL %TMPDIR%\google.out\r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i google -f reference\google.js -o arc -F %TMPDIR%\google.out\r
+@echo off\r
+@echo.\r
+CALL :COMPARE %TMPDIR%\google.out reference\google.arc\r
+\r
+REM \r
+REM DeLorme .an1 tests\r
+REM \r
+DEL %TMPDIR%\an1.out\r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i an1 -f reference\foo.an1 -o csv -F %TMPDIR%\an1.out\r
+@echo off\r
+@echo.\r
+CALL :COMPARE %TMPDIR%\an1.out reference\an1-in.ref\r
+\r
+DEL %TMPDIR%\an1.out\r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i an1 -f reference\foo.an1 -o an1 -F %TMPDIR%\an1.out\r
+@echo off\r
+@echo.\r
+CALL :COMPARE %TMPDIR%\an1.out reference\an1-an1.ref\r
+\r
+DEL %TMPDIR%\an1.out\r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i xmap -f reference\xmap -o an1 -F %TMPDIR%\an1.out \r
+@echo off\r
+@echo.\r
+CALL :COMPARE %TMPDIR%\an1.out reference\an1-out.ref\r
+\r
+DEL %TMPDIR%\an1.out\r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i google -f reference\google.js -o an1 -F %TMPDIR%\an1.out\r
+@echo off\r
+@echo.\r
+CALL :COMPARE %TMPDIR%\an1.out reference\an1-line-out.ref\r
 \r
 REM \r
 REM XCSV "human readable" tests\r
@@ -901,3 +975,36 @@ REM
 @echo off\r
 @echo.\r
 \r
+REM \r
+REM 'tabsep' isn't really tested in any non-trivial way, but we do exercise\r
+REM it.\r
+REM \r
+\r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i geo -f geocaching.loc  -o tabsep -F - | ${PNAME} -i tabsep -f - -o geo -F %TMPDIR%\tabsep.out\r
+%PNAME% -i geo -f geocaching.loc  -o geo -F %TMPDIR%\geotabsep.out\r
+@echo off\r
+@echo.\r
+\r
+REM \r
+REM Now do the same for custom - it has the same issues.\r
+REM \r
+\r
+CALL :COMPARE %TMPDIR%\tabsep.out %TMPDIR%\geotabsep.out\r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i geo -f geocaching.loc  -o custom -F - | ${PNAME} -i custom -f - -o geo -F %TMPDIR%\custom.out\r
+%PNAME% -i geo -f geocaching.loc  -o geo -F %TMPDIR%\geocustom.out\r
+@echo off\r
+@echo.\r
+\r
+REM \r
+REM Write something to the various output-only formats\r
+REM \r
+@echo on\r
+@echo Testing...\r
+%PNAME% -i geo -f geocaching.loc -o text -F %TMPDIR%\text.out -o html -F %TMPDIR%\html.out -o vcard -F %TMPDIR%\vcard.out #-o palmdoc -F %TMPDIR%\pd.out\r
+@echo off\r
+@echo.\r
+\r
index 545da82107dba7ce778f423a0e4ae249d4f25a45..750d139888b6ab187a1b67146ad24dabaae94351 100644 (file)
@@ -104,7 +104,7 @@ route_add_wpt(route_head *rte, waypoint *wpt)
                char tmpnam[10];
                snprintf(tmpnam, sizeof(tmpnam), "RPT%03d",rte_waypts);
                wpt->shortname = xstrdup(tmpnam);
-               wpt->shortname_is_synthetic = 1;
+               wpt->wpt_flags.shortname_is_synthetic = 1;
        }
 }
 
index 14305d98c7162b2b26d6e4a084c9d8b18e4722d1..f45633a65b1330ba5d53e4d053e6fe5a67bd0bb4 100644 (file)
@@ -50,7 +50,7 @@ waypt_dupe(const waypoint *wpt)
                tmp->url = xstrdup(wpt->url);
        if (wpt->url_link_text)
                tmp->url_link_text = xstrdup(wpt->url_link_text);
-       if (wpt->icon_descr && wpt->icon_descr_is_dynamic)
+       if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic)
                tmp->icon_descr = xstrdup(wpt->icon_descr);
        if (wpt->gc_data.desc_short.utfstring) {
                tmp->gc_data.desc_short.utfstring = 
@@ -262,7 +262,7 @@ waypt_free( waypoint *wpt )
        if (wpt->url_link_text) {
                xfree(wpt->url_link_text);
        }
-       if (wpt->icon_descr && wpt->icon_descr_is_dynamic) {
+       if (wpt->icon_descr && wpt->wpt_flags.icon_descr_is_dynamic) {
                xfree((char *)(void *)wpt->icon_descr);
        }
        if (wpt->gpx_extras) {